//
//  ListCollection.m
//  OpperV1.0
//
//  Created by Le Dung on 4/27/13.
//  Copyright (c) 2013 LeDung. All rights reserved.
//

#import "ListCollection.h"
#import "ControlImport.h"
@implementation ListCollection
@synthesize dataArray;
@synthesize indexPress;
@synthesize delegate;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self setBackgroundColor:[UIColor redColor]];
               
    }
    return self;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
  return   dataArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 30;
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
 
    
    UITableViewCell * cell =nil;
    
    static NSString * CellIdentifier = @"Cell";
    cell =[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(cell==nil)
    {
        cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    [cell.textLabel setFont:[UIFont systemFontOfSize:14]];
    
    ListObject *listObject =dataArray[indexPath.row];
    
    cell.textLabel.text=listObject.objectName;
    return cell;
}
- (void)drawRect:(CGRect)rect
{
    UITableView *table =[[UITableView alloc]initWithFrame:self.bounds];
    [self addSubview:table];
    table.delegate=self;
    table.dataSource=self;
    [table release];
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    ListObject *listObject =dataArray[indexPath.row];
    [[self delegate] indexPress:dataArray[indexPath.row] andTagRespone:indexPress andIndexObject:listObject.objectId andNameRespone:listObject.objectName];
}
@end
